package io.renren.common.constants.enums;

import com.alibaba.fastjson.annotation.JSONType;
import io.renren.common.utils.json.EnumValueDeserializer;
import lombok.Getter;

/**
 * @program: simida
 * @description: 媒体类型枚举
 * @author: miaoguoxin
 * @create: 2019-10-30 09:19
 **/
@Getter
@JSONType(deserializer = EnumValueDeserializer.class)
public enum MediaType implements EnumValue{
    AUDIO(1,"音频"),
    VIDEO(2,"视频"),
    IMAGE(3,"图片")
    ;

    /**值*/
    private int value;
    /**描述*/
    private String desc;

    MediaType(int value, String desc) {
        this.value = value;
        this.desc = desc;
    }

    /**
     * 获取枚举
     *
     * @return
     */
    public static MediaType getByCode(int code) {
        for (MediaType e : values()) {
            if (e.getValue() == code) {
                return e;
            }
        }
        return IMAGE;
    }
    @Override
    public int value() {
        return this.value;
    }
}